<%-- 
    Document   : raportTmpl
    Created on : Feb 13, 2014, 12:45:45 PM
    Author     : Marek
--%>
<%@page import="entities.users.FormSigner"%>
<%@page import="entities.tools.Form"%>
<%@page import="entities.tools.FilledForm"%>
<%@page import="entities.tools.Answer"%>
<%@page import="util.other.ENUMQuestionTypes"%>
<%@page import="entities.tools.Question"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %> 
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>

<c:set var="formAction" value=""/>
<c:if test="${not empty sessionScope.getParamSelect}">
    <c:set var="formAction" value="?select=${sessionScope.getParamSelect}"/>    
</c:if>


<form method="POST" action="<c:url value="${formUrl}"/>"/>
<div style="width:97%;height:100%;">
    <div><ul><li><a href="<c:url value="?generate=true"/>">New form</a></li></ul></div>
    <div style="display:table;width:100%;">
        <div style="display:table-row;width:100%;">
            <div style="display:table-cell;width:80%;overflow:scroll;">
                <table border="1" style="width:100%;font-size:10px;">
                    <tr>
                        <th>id</th>
                        <th>Name</th>
                        <th>Description</th>
                    </tr>
                    <c:forEach items="${forms}" var="form">
                        <c:set var="selectedRowStyle" value=""/>
                        <c:choose>
                            <c:when test="${not empty sessionScope.getParamSelect and form.id eq sessionScope.getParamSelect }">
                                <c:set var="selectedRowStyle" value="background-color:#EEEEEE;border:1px solid black;"/>                  
                            </c:when>
                        </c:choose>
                        <tr style="${selectedRowStyle}">
                            <td>${form.id}</td>
                            <td>${form.name}</td>
                            <td>${form.description}</td>
                            <td><a href="<c:url value="?delete=${form.id}"/>">Delete</a></td>
                            <td><a href="<c:url value="?select=${form.id}"/>">Select</a></td>
                        </tr>
                    </c:forEach>
                </table>    
            </div>
            <div style="display:table-cell;width:20%;">
                <c:choose>
                    <c:when test="${not empty sessionScope.getParamSelect}">
                        <table style="wdirh:100%;">
                            <tr>
                                <td>Name</td>
                                <td><input type="text" name="name" value="${form.name}"></td>
                            </tr>
                            <tr>
                                <td>Description</td>
                                <td><textarea name="description">${form.description}</textarea></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input value="Cancel" type="button"/><!-- change this button to image a link-->
                                    <input value="Save" type="submit"/><!-- use it as a image button same as at global form-->
                                </td>
                            </tr>
                        </c:when>
                        <c:otherwise>
                            Form entity editor is visible here
                        </c:otherwise>
                    </c:choose>
            </div>
        </div>
    </div>

</div>
</form>
